//************************************************
//  *Author：jxx
//  *QQ：283591387
//  *自定义业务逻辑扩展
//************************************************
export default function() {
	return {
		methods: {
			onInited() { //页面参数初始化
				//设置table超出换行显示
				//this.textInline = false;

				//设置列宽度
				//this.columns[1].width = 70;

				//设置table为水平显示或者list列表显示
				//this.direction = 'horizontal'//list
				//如果为list列表显示，指定list的标题列
				//this.titleField="字段";

				//设置自定义格式显示
				//this.columns.forEach(column=>{
				// 	if(column.field=='字段'){
				//      //自定义格式化显示,在下面的formatter实现具体逻辑
				// 		//column.formatter=true;

				//      //指定字段为date类型不显示时分秒
				//      //column.type="date";

				//      //设置列宽度
				//      //column.width = 70;
				// 	}
				// })

				//页面打开时禁用加载数据
				//this.load=false;
				//页面打开时默认弹出查询框
				//this.searchModel = true;
				this.buttons.push({ //view-grid添加自定义按钮 byhuangxs
					name: "审核/提交",
					icon: 'checkmark',
					hidden: false,
					type: 'primary',
					onClick: () => {
						this.otherclick(this.currentRow);
					}
				});
				/* this.columns.push({
					field:"操作",
					title:"操作",
					formatter:true,
				}
				) */

				/* this.editFormOptions.forEach(x => { //编辑页面的字段变为只读，by huangxs
					//console.log(x);
					x.readonly = true;
				}) */
			},
			rowButtons(index,row){
				let buttons=[{
					text:"明细表",
					icon:"list",
					type:"primary",
					shape:"circle",
					disabled:false,
					
				},
				{
					text:"提交",
					icon:"checkmark",
					type:"primary",
					shape:"circle",
					disabled:false,
					
				}];
				return buttons;
			},
			rowButtonClick(btn,index,row){
				if (btn.text=="明细表"){
					//console.log(row.reim_id)
					//let str_id=row.reim_id+""
					//this.$toast(str_id);//$toast只能输出字符串
					uni.setStorageSync("curr_row", row);
					let url = "/pages/mytable/Fk_reim/Fk_reimlist_shoug?reimid=" + row.reim_id;
					uni.navigateTo({
						url: url
					})
				}
				if (btn.text=="提交"){
					//this.model = false;
					let url = "/pages/mytable/Fk_reim/check_tijiao?reimid=" + row.reim_id;
					uni.navigateTo({
						url: url
					})
					
					//console.log(curr_row);
					uni.setStorageSync("curr_row", row);
					//console.log( uni.getStorageSync("curr_row").reim_id);
				}
			},
			formatter(row, column, index) { //自定义格式化
				// if(column.field=='xx'){
				//  return '<a style="color:red;">' + row[column.field] + '</a>';
				// }
				//return row[column.field]
			},
			rowClick(index, row, column) { //行点击事件(默认触发编辑)
				//console.log(row.reim_id)
				uni.setStorageSync("curr_row", row)
				return true;
			},
			searchBefore(params) { //查询前
				let wheres = [{
					'name': 'typeid',
					'value': '1', //1费用报销,2为差旅报销
					//'displayType': 'like'//设置为模糊查询,其他不需要设置
				}];
				params.wheres.push(...wheres);
				return true;
			},
			searchAfter(result, alldata) { //查询ViewGird表数据后param查询参数,result回返查询的结果zuo
				//_alldata = alldata; //查询后从服务器传入所有数据  huangxs
				uni.setStorageSync("_alldata", alldata)
				return true;
			},
			updateBefore(formData) { //更新保存前操作
				return true;
			},
			addBefore(formData) { //新建保存前操作
				return true;
			},
			searchFormOnChange(field, value) { //查询弹出框下拉框或日期选中事件
				//if(field=="字段"){
				// 	console.log(value)
				//}
			},

			editFormOnChange(field, value) { //新建编辑弹出框下拉框或日期选中事件
				//if(field=="字段"){
				// 	console.log(value)
				//}
			},
			otherclick(curr_row) {
				this.model = false;
				let url = "/pages/mytable/Fk_reim/check_tijiao?reimid=" + curr_row.reim_id;
				uni.navigateTo({
					url: url
				})

				//console.log(curr_row);
				uni.setStorageSync("curr_row", curr_row);
				//console.log( uni.getStorageSync("curr_row").reim_id);
			},
		
		}
	}
}
